#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         myName

 Script Function:
	Template AutoIt script.

#ce ----------------------------------------------------------------------------
#include <File.au3>
#include <Array.au3>
; Script Start - Add your code below here
Global $DllFolderPath = "C:\Dll\"
Global $ExeFolderPath = "C:\Exe\"
Global $dllPath = "ImageOperate.dll"


Func Common_DllCopy()
	Local $FileList = _FileListToArray($DllFolderPath)

	If @error <> 1 And @error <> 4 Then
		_ArrayDisplay($FileList, "$FileList")
		For $i=1 To $FileList[0]
			FileCopy($DllFolderPath&$FileList[$i],$ExeFolderPath&$FileList[$i],1)
		Next
	EndIf
	
EndFunc

Func Common_DllRemove()
	Local $FileList1 = _FileListToArray($DllFolderPath)
	_ArrayDisplay($FileList1, "$FileList")
	If @error <> 1 And @error <> 4 Then
		For $j=1 To $FileList1[0]
			FileDelete($ExeFolderPath&$FileList1[$j])
		Next
	EndIf	
EndFunc


Func Common_GetImageDPI ($file)
	
	$dll = DllOpen($dllPath)
	$result = DllCall($dll, "int","Auto_GetImageDPI", "str",$file)
	DllClose($dll)

	If Not @error Then
		Return $result[0]
	Else
		Return @error
	EndIf
	DllClose($dll)

EndFunc

MsgBox("","",Common_GetImageDPI("C:\Users\Top\Desktop\sample\Scan0007.jpg"))


Func Common_GetImageType ($file)
	$dll = DllOpen($dllPath)
	$result = DllCall($dll, "int","Auto_GetImageType", "str",$file)
	DllClose($dll)
	
	If Not @error Then
		Local $msg
		Switch $result[0]
			Case 0
				$msg = "BlackWhite"
			Case 1 To 3
				$msg = "Color"
			Case 4 To 5
				$msg = "Gray"
			Case 6 To 9
				$msg = "Color"
			Case 10
				$msg = "Gray"
			Case Else
				$msg = "Unknow"
		EndSwitch
		;MsgBox(0, Default, $msg)
		Return $msg
	Else
		Return @error
	EndIf
	DllClose($dll)
EndFunc

Func Common_GetImageHeight ($file)
	$dll = DllOpen($dllPath)
	$result = DllCall($dll, "int","Auto_GetImageHeight", "str",$file)
	DllClose($dll)
	
	If Not @error Then
		Return $result[0]
	Else
		Return @error
	EndIf
	DllClose($dll)
EndFunc


Func Common_GetImageWidth ($file)
	$dll = DllOpen($dllPath)
	$result = DllCall($dll, "int","Auto_GetImageWidth", "str",$file)
	DllClose($dll)
	
	If Not @error Then
		Return $result[0]
	Else
		Return @error
	EndIf
	DllClose($dll)
EndFunc

Func Common_ScanImageCompare($file,$color,$dpi,$width,$hight)
	If $color = Common_GetImageType ($file) Then
		If $dpi = Common_GetImageDPI ($file) Then
			If $dpi = Common_GetImageDPI ($file) Then
				If $width = Common_GetImageWidth ($file) Then
					If $hight = Common_GetImageHeight ($file) Then
						Return 1
					Else
						Return 0
					EndIf
				Else
					Return 0
				EndIf	
			Else
				Return 0
			EndIf
		Else
			Return 0
		EndIf	
	Else
		Return 0
	EndIf
EndFunc
